#pragma once

#pragma unmanaged

#include <BWSAL\BuildUnit.h>

#pragma managed

#include "..\BWAPI\Unit.h"
#include "Build.h"
#include "Interfaces\IMetaUnit.h"

using namespace BroodWar::Api;

namespace BroodWar
{
	namespace Addon
	{
		ref class Task;

		public ref class BuildUnit sealed : public IMetaUnit
		{
		internal:
			bool dispose;
			BWSAL::BuildUnit* instance;

			BuildUnit(BWSAL::BuildUnit* unit);
			~BuildUnit();
			!BuildUnit();
		public:
			BuildUnit(Task^ task);
			BuildUnit(Api::Unit^ unit);

			virtual property BuildUnit^ BuilderUnit { BuildUnit^ get(); }
			virtual property Build^ Type { Build^ get(); }

			void SetUnit(Unit^ unit);
			void SetTask(Task^ task);
			property bool IsReal { bool get(); }
			property Api::Unit^ Unit { Api::Unit^ get(); }
			property Addon::Task^ Task { Addon::Task^ get(); }
			
			static BuildUnit^ GetBuildUnit(Api::Unit^ unit);
			static BuildUnit^ GetBuildUnitIfExists(Api::Unit^ unit);
			static void SetBuildUnit(Api::Unit^ unit, BuildUnit^ buildUnit);
			
			/*struct state
			{
				int m_availableSince;
				BuildType m_type;
				int m_nextLarvaSpawnTime;
				int m_larvaCount;
				BuildType m_addon;
			};
			state m_currentState;
			state m_planningData;*/
		};

		BuildUnit^ ConvertBuildUnit(BWSAL::BuildUnit* unit);
		BWSAL::BuildUnit* ConvertBuildUnit(BuildUnit^ unit);
	}
}
